package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MyCar;
import com.ruoyi.system.service.IMyCarService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车间设备信息Controller
 * 
 * @author ruoyi
 * @date 2023-12-17
 */
@RestController
@RequestMapping("/system/car")
public class MyCarController extends BaseController
{
    @Autowired
    private IMyCarService myCarService;

    /**
     * 查询车间设备信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:car:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyCar myCar)
    {
        startPage();
        List<MyCar> list = myCarService.selectMyCarList(myCar);
        return getDataTable(list);
    }

    /**
     * 导出车间设备信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:car:export')")
    @Log(title = "车间设备信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MyCar myCar)
    {
        List<MyCar> list = myCarService.selectMyCarList(myCar);
        ExcelUtil<MyCar> util = new ExcelUtil<MyCar>(MyCar.class);
        util.exportExcel(response, list, "车间设备信息数据");
    }

    /**
     * 获取车间设备信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:car:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(myCarService.selectMyCarById(id));
    }

    /**
     * 新增车间设备信息
     */
    @PreAuthorize("@ss.hasPermi('system:car:add')")
    @Log(title = "车间设备信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCar myCar)
    {
        return toAjax(myCarService.insertMyCar(myCar));
    }

    /**
     * 修改车间设备信息
     */
    @PreAuthorize("@ss.hasPermi('system:car:edit')")
    @Log(title = "车间设备信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCar myCar)
    {
        return toAjax(myCarService.updateMyCar(myCar));
    }

    /**
     * 删除车间设备信息
     */
    @PreAuthorize("@ss.hasPermi('system:car:remove')")
    @Log(title = "车间设备信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(myCarService.deleteMyCarByIds(ids));
    }
}
